package com.mega.fe.mixins;

import com.mega.fe.god.GodGameRenderer;
import com.mega.fe.util.BaseInit;
import com.mega.fe.util.MEGA;
import net.minecraft.client.Minecraft;
import net.minecraft.client.main.GameConfig;
import net.minecraft.client.renderer.GameRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(Minecraft.class)
public class MinecraftMixin {
    @Shadow public GameRenderer gameRenderer;

    @Inject(method = "<init>", at = @At("RETURN"))
    private void init(GameConfig p_91084_, CallbackInfo ci) {
        BaseInit.replaceBus();
        BaseInit.EVENT_BUS().start();
    }
    @Inject(method = "run", at = @At("HEAD"))
    private void run(CallbackInfo ci) {
        if (gameRenderer != null) {
            try {
                MEGA.replaceClass(gameRenderer, GodGameRenderer.class);
            } catch (Throwable e) {
                throw new RuntimeException(e);
            }
        }
    }
}
